
let paginationBev = Behavior({
  data: {
    dataArray: [],
    total: null,
    noneResult: false,
    loading: false
  },

  methods: {
    setMoreData(dataArray) {
      const tempArray = this.data.dataArray.concat(dataArray)
      this.setData({
        dataArray: tempArray
      })
    },

    hasMore() {
      if(this.data.dataArray.length >= this.data.total) {
        return false
      }else{
        return true
      }
    },

    getCurrentStart() {
      return this.data.dataArray.length
    },

    setTotal(total) {
      this.data.total = total
      if(total == 0) {
        this.setData({
          noneResult: true
        })
      }
    },

    isLocked() { // 是否有锁的状态
      return this.data.loading ? true : false
    },

    locked() { // 加锁
      // this.data.loading = true
      this.setData({
        loading: true
      })
    },

    unlocked() { // 解锁
      // this.data.loading = false
      this.setData({
        loading: false
      })
    },


    initialize() { // 初始化数据
      // this.data.dataArray = []
      this.setData({
        dataArray: [],
        noneResult: false,
        loading: false
      })
      this.data.total = null
    }
  }
})


export {
  paginationBev
}